﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using Ruleweaver.Rules;

namespace Ruleweaver
{
	public class Specification<T> : Check<T>, ISpecifiable<T>
	{
		public Specification(T target, Rule rule, ISpecificationProvider provider) : base(target)
		{
			Contract.Requires(rule != null);
			Contract.Requires(provider != null);

			Rule = rule;
			Provider = provider;
		}

		#region ISpecifiable

		public Rule Rule { get; private set; }
		
		public ISpecificationProvider Provider { get; private set; }

		#endregion

		public override bool Apply()
		{
			return Provider.Execute(Target, Rule);
		}
	}
}